fix: use txMeta.actionId as a temporary key to capture data for non-STX where it fails before submission#7696
Merged
infiniteflower merged 14 commits intomainfrom Jan 22, 2026
Merged
Conversation
7 tasks
…ils before submission
- Make bridgeTxMeta optional in StartPollingForBridgeTxStatusArgs type - Add explicit validation in startPollingForBridgeTxStatus requiring bridgeTxMeta.id - Add test for undefined bridgeTxMeta case
ee23916 to
ef54173
Compare
Extract history key determination logic into a pure function to improve test coverage. The function validates that either actionId or bridgeTxMetaId is provided, throwing if neither is available.
Extract intent validation logic into a pure function to improve test coverage. The function validates that intent data exists in the quote response, throwing if missing.
…istory Since bridgeTxMeta is now optional, we don't need to pass an empty object when adding pre-submission history. The actionId is used as the key instead.
ghgoodreau
approved these changes
Jan 22, 2026
github-merge-queue bot
pushed a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Jan 27, 2026
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR attempts to look up historyItems by `actionId` where possible in order to set the `provider` field properly in analytics on failed txs. It also fixes an issue where swaps were not being picked up properly on the tx activity list. Also if you notice, there is no more flash of `Swaps Transaction` anymore before turning into `Swap X to Y`, this is because we now always have the `historyItem` data for non-STX txs. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591 Related to MetaMask/core#7696 ## **Manual testing steps** ```gherkin Feature: fix for provider not being set on failed txs Scenario: user is trying to swap Given user is using a smart account on Polygon and trying to swap an ERC20 that needs an approval When user swaps Then the swap tx fails ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> #### Polygon, Smart Account, ERC20 Source token https://github.com/user-attachments/assets/c95d838c-f688-403c-abf2-58f3ca74228b <img width="1436" height="816" alt="Screenshot 2026-01-22 at 1 23 19 PM" src="https://github.com/user-attachments/assets/576add03-9312-4cc5-9ff5-1661bc138237" /> ### OP, Non smart account, non STX, ERC20 source token Notice how the tx history is immediately populated with the swap details https://github.com/user-attachments/assets/6de11569-736c-4d15-923d-9512df695b8a ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Improves history association and activity rendering for swaps/bridges. > > - `useBridgeTxHistoryData`: adds lookup by `actionId` (in addition to tx id and `originalTransactionId`); new tests cover actionId matching and existing paths > - `TransactionElement`: treats swaps with a matching history item as unified, uses `getSwapBridgeTxActivityTitle` for titles, and routes clicks through unified handler (eliminates transient "Swaps Transaction" label) > - `activity/index.ts`: tightens MetaMask Pay filtering for bridge receives by ensuring `txMetaId` exists before matching required ids > - Bumps deps: `@metamask/bridge-status-controller` to `^64.4.5` and `@metamask/bridge-controller` to `^64.8.2` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 408e330. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
This PR changes the way that
BridgeStatusController's history items are keyed for non-STX to improve status tracking and addressing some gaps in analytics.actionId, keyhistoryItembyactionIdand add to state BEFORE submitting tx. Previously we would not even have ahistoryItem, if the the tx failed before being submitted on chain.actionIdtoTransactionController.addTransaction()as a part of the requestactionIdto theirtxMeta.idtransactionFailedusetxMeta.actionIdto identify txs that failed before actually being submitted on chain and handle metricsYou can test this by using a Smart Account on Polygon and attempting to do a USDT > POL swap that requires an approval. You should see error
In flight transaction limit reached for delegate accountsin the logs. When you check Mixpanel, theproviderfield should be properly filled out. A video of the whole process in in MetaMask/metamask-mobile#25010.References
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3591
Related to MetaMask/metamask-mobile#25010
Checklist
Note
Improves robustness of transaction tracking and analytics around pre-submission failures.
actionIdas a temporary history key for non-batch EVM submissions; storeactionIdinBridgeHistoryItemand rekey totxMeta.idafter successful submission (updatingtxMetaIdandsrcTxHash)TransactionController:transactionFailed, look up history bytxMeta.idthenactionIdto mark failed and track metrics; skip tracking forrejectedstatusbridgeTxMeta.idrequirement instartPollingForBridgeTxStatus; exclude items withouttxMetaIdfrom restart pollinggetHistoryKeyandgetIntentFromQuoteutils; makeBridgeHistoryItem.txMetaIdoptional andStartPollingForBridgeTxStatusArgs.bridgeTxMetaoptional; expand tests and snapshots accordinglyWritten by Cursor Bugbot for commit 385b6d8. This will update automatically on new commits. Configure here.